﻿@page "/comic/index"

@using HentaiBlazor.Data.Comic
@using HentaiBlazor.Ezcomp

<PageContainer Title="热辣漫画">
    <Space Style="float: right;">
        <SpaceItem>
            <SortableList Sortable="@Sortable" OnSort="() => Search()" />
        </SpaceItem>
    </Space>

    <Space Style="margin-bottom: 0.5rem;">
        <SpaceItem>
            <Input Prefix="@_filter" Placeholder="关键字" Style="width: 12rem;"
                   @bind-Value="searchKeyword" />
        </SpaceItem>
        <SpaceItem>
            <Input Prefix="@_folder" Placeholder="目录" Style="width: 12rem;"
                   @bind-Value="searchCatalog" />
        </SpaceItem>
        <SpaceItem>
            <Input Prefix="@_team" Placeholder="作者" Style="width: 12rem;"
                   @bind-Value="searchAuthor" />
        </SpaceItem>
        <SpaceItem>
            <Button Type="@(searchFavorite ? ButtonType.Default : ButtonType.Primary)" @onclick="async () => { searchFavorite = false; await Search(); }">全部</Button>
            <Button Type="@(searchFavorite ? ButtonType.Primary : ButtonType.Default)" @onclick="async () => { searchFavorite = true; await Search(); }">收藏</Button>
        </SpaceItem>
    </Space>

    <Pagination Style="margin-bottom: 0.5rem;" 
                Total="CBookEntitiesPaged.TotalCount"
                PageSize="CBookEntitiesPaged.PageSize"
                Current="CBookEntitiesPaged.PageIndex"
                OnChange="Paging"
                ShowQuickJumper="true" />

    <AntList ItemLayout="ListItemLayout.Horizontal"
             Grid="gutter" DataSource="CBookEntitiesPaged.Data">
        <ListItem Grid="gutter">
            <CardBook Book="@context" OnDetail="() => OpenDetail(context.Id, context.Title)"></CardBook>
        </ListItem>
    </AntList>

    <Pagination Total="CBookEntitiesPaged.TotalCount"
                PageSize="CBookEntitiesPaged.PageSize"
                Current="CBookEntitiesPaged.PageIndex"
                OnChange="Paging"
                ShowQuickJumper="true" />

</PageContainer>

@code
{
RenderFragment _folder =@<Icon Type="folder" />;
RenderFragment _team =@<Icon Type="team" />;
RenderFragment _filter =@<Icon Type="filter" />;

public ListGridType gutter = new ListGridType
{
Gutter = 8,
Xs = 2,
Sm = 2,
Md = 4,
Lg = 4,
Xl = 5,
Xxl = 5,
Column = 10
};

}
